<?php

$flags = Array(
    0 => 'Gossip',    // 1
    1 => 'Quest Giver',    // 2
    2 => 'Vendor', // 4
    3 => 'Taxi', // 8
    4 => 'Trainer',    // 16
    5 => 'Spirit Healer',    // 32
    6 => 'Guard', // 64
    7 => 'Inn Keeper', // 128
    8 => 'Banker', // 256
    9 => 'Petitioner', // 512
    10 => 'Tabard Vendor', // 1024
    11 => 'Battle Master', // 2048
    12 => 'Auctioneer', // 4096
    13 => 'Stable Master',    // 8192
    14 => 'Armorer', // 16384
);

?>
<style>
form {
    font-size: 11px;
    font-family: Verdana;
}
</style>
<form action="flags.php" method="POST">
<?php


$x = 0;
foreach($flags as $key => $value){
    echo '<label for="flag_'.$value.'">'.$value.'</label>';
    echo '<input type="checkbox" value="'.$key.'" name="npcflag[]" id="flag_'.$value.'"/>&nbsp;&nbsp;';
    $x++;
    if ($x  > 4){
        echo '<br/>';
        $x = 0;
    };
};

?>
<input type="submit" value="Get Flag"/>
</form>

<?php

$npcflag = 0;
if (!empty($_POST['npcflag']))
    foreach($_POST['npcflag'] as $value)
        $npcflag += pow(2, $value);    // build our flag
echo '<PRE>';
define('endl', "\n");
echo 'NPCFLAG: '.$npcflag.endl;

for($i = count($flags) - 1; $i >= 0; $i--)
    if ((pow(2, $i) & $npcflag) > 0)    // check for flags
        echo "  is &raquo;  ".$flags[$i].endl;

echo '</PRE>';

?>